//
//  BRankListTopCell.m
//  DistributorAB
//
//  Created by LZY on 2019/9/29.
//  Copyright © 2019 主事丫环. All rights reserved.
//

// B级经销商排行榜前三名cell

#import "BRankListTopCell.h"
#import "ZYLookLeaderboardModel.h"

@interface BRankListTopCell ()
@property (nonatomic, strong) UILabel *lblLeft;//左侧(第二名)
@property (nonatomic, strong) UILabel *lblCenter;//中间(第一名)
@property (nonatomic, strong) UILabel *lblRight;//右侧(第三名)

@end

@implementation BRankListTopCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupViewAction];
    }
    return self;
}
#pragma mark - 界面布局方法
- (void)setupViewAction{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.contentView.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    
    UIImageView *ivBg = [[UIImageView alloc] initWithFrame:CGRectMake(32, 0, kScreen_Width - 64, 228)];
    ivBg.image = imgname(@"rank_top_bg");
    [self.contentView addSubview:ivBg];
    
    UIImageView *ivRankBg = [[UIImageView alloc] initWithFrame:CGRectMake(2, 45, kScreen_Width - 4, 183)];
    ivRankBg.image = imgname(@"rank_top_rank_bg");
    [self.contentView addSubview:ivRankBg];
    
    _lblLeft = [UILabel new];
    _lblLeft.text = @"暂无";
    _lblLeft.textColor = kColorWithHex(0x333333);
    _lblLeft.textAlignment = NSTextAlignmentCenter;
    _lblLeft.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_lblLeft];
    
    _lblCenter = [UILabel new];
    _lblCenter.text = @"暂无";
    _lblCenter.textColor = kColorWithHex(0x333333);
    _lblCenter.textAlignment = NSTextAlignmentCenter;
    _lblCenter.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:_lblCenter];
    
    _lblRight = [UILabel new];
    _lblRight.text = @"暂无";
    _lblRight.textColor = kColorWithHex(0x333333);
    _lblRight.textAlignment = NSTextAlignmentCenter;
    _lblRight.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:_lblRight];
    
    [_lblLeft mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-43);
        make.leading.equalTo(ivRankBg.mas_leading);
        make.size.mas_equalTo(CGSizeMake(ivRankBg.width / 3.0, 22));
    }];
    
    [_lblCenter mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.lblLeft.mas_trailing);
        make.centerY.equalTo(self.lblLeft.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(ivRankBg.width / 3.0, 22));
    }];
    
    [_lblRight mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.lblCenter.mas_trailing);
        make.centerY.equalTo(self.lblLeft.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(ivRankBg.width / 3.0, 22));
    }];
    
}
#pragma mark - 数据更新
- (void)setRankListArray:(NSMutableArray *)rankListArray{
    _rankListArray = rankListArray;
    if (rankListArray.count > 0) {
        
        __weak typeof(self) weakself = self;
        [rankListArray enumerateObjectsUsingBlock:^(ZYLookLeaderboardModel  *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            switch (idx) {
                case 0:
                {
                    weakself.lblCenter.text = obj.area_name.length > 0 ? obj.area_name : @"暂无";
                }
                    break;
                case 1:
                {
                    weakself.lblLeft.text = obj.area_name.length > 0 ? obj.area_name : @"暂无";
                }
                    break;
                case 2:
                {
                    weakself.lblRight.text = obj.area_name.length > 0 ? obj.area_name : @"暂无";
                }
                    break;
                    
                default:
                    break;
            }
        }];
    }
}

+ (CGFloat)defaultHeight{
    return 233.0;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
